package calendar;

import java.text.SimpleDateFormat;
import java.util.Calendar;

/**
 *
 * 根据开始时间 和 结束时间 按天遍历
 *
 * Created by Zhou_Bing on 2019/4/17.
 */
public class ForEach {

    public static void main(String[] args){

        /* 2018-01-01 到 2019-04-09  */

        Calendar startTime = Calendar.getInstance();
        startTime.set(2018,0,1,0,0,0);
        Calendar endTime = Calendar.getInstance();
        endTime.set(2019,3,9,0,0,0);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        while(startTime.getTime().getTime()<=endTime.getTime().getTime()){
            System.out.println(sdf.format(startTime.getTime()));
            if(startTime.get(Calendar.DAY_OF_WEEK)==2){
                System.out.println("生成周维护的应维护");
            }
            if(startTime.get(Calendar.DAY_OF_MONTH)==1){
                System.out.println("生成月维护的应维护");
            }
            if(startTime.get(Calendar.MONTH)==0 && startTime.get(Calendar.DAY_OF_MONTH)==1){
                System.out.println("生成年维护的应维护");
            }

            startTime.add(Calendar.DATE,1);
        }
//        System.out.println(sdf.format(startTime.getTime())+"~~~~~~~"+sdf.format(endTime.getTime()));

    }

}
